﻿using PureMVC.Interfaces;
using System;

namespace Rail.Start.Viewer
{
    public class DemoFormMediator: PureMVC.Patterns.Mediator, IMediator
    {
        DemoForm m_DemoForm;
        public DemoFormMediator(DemoForm viewComponent)
               : base(NAME, viewComponent)
        {
            m_DemoForm = viewComponent;
            m_DemoForm.Value1.ValueChanged += ValueChanged;
            m_DemoForm.Value2.ValueChanged += ValueChanged;
        }
        /// <summary>
        /// 计算
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ValueChanged(object sender, EventArgs e)
        {
            m_DemoForm.Result.Text = (m_DemoForm.Value1.Value + m_DemoForm.Value2.Value).ToString();
            SendNotification(Rail.Commons.Messages.SHOWINFOMESSAGE,"计算结果为：" + m_DemoForm.Result.Text);
        }
    }
}
